package com.shuyuwl.core.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 领域模型的父类，定义了系统内所有领域模型的通用属性
 * @Author ZChao
 * @Date 2019/9/3
 **/
@Data
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class AbstractBaseDomain implements Serializable {

    @Id
    @Column(name = "id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    protected Long id;

    @CreatedBy
    @Column(name = "create_by", length = 255, nullable = false)
    protected String createBy;

    @CreatedDate
    @Column(name = "create_date", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    protected Date createDate;

    @LastModifiedBy
    @Column(name = "update_by", length = 255, nullable = false)
    protected String updateBy;

    @LastModifiedDate
    @Column(name = "update_date", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    protected Date updateDate;

    @Column(name = "status", nullable = false)
    protected Byte status;

}
